bitkeeper revision 1.1346.1.1 (42670505dNhgnJm5dQD81pCalXMZgw)
authoriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Thu, 21 Apr 2005 01:42:29 +0000 (01:42 +0000)
committeriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Thu, 21 Apr 2005 01:42:29 +0000 (01:42 +0000)
manual merge

1  2 
.rootkeys
tools/libxc/Makefile
tools/libxc/xc.h
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendClient.py
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/server/SrvDomain.py
tools/python/xen/xm/main.py
xen/common/schedule.c
xen/include/public/sched_ctl.h
xen/include/xen/sched-if.h

diff --cc .rootkeys
index 46c7621e13b48728fdd2bbf5d41d8b0d2e459b78,9d9bd04adefa14442e684e8cd99db5b1f94288ee..6a77bc3395c92050951399a325f83ca6452c40ac
+++ b/.rootkeys
  4187c1c7IWmBinGdI19kL4MuZ6RLbQ docs/check_pkgs
  3f9e7d60PWZJeVh5xdnk0nLUdxlqEA docs/figs/xenlogo.eps
  418a3248xjIqmNKo0v_XQSfAvlBGFw docs/html.sty
 +41c0c4116itF389v0CEWcmzue6zJkA docs/misc/VMX_changes.txt
  4022a73cgxX1ryj1HgS-IwwB6NUi2A docs/misc/XenDebugger-HOWTO
  412f4bd9sm5mCQ8BkrgKcAKZGadq7Q docs/misc/blkif-drivers-explained.txt
 +420b949cy9ZGzED74Fz_DaWlK7tT4g docs/misc/crashdb.txt
 +4251a1f82AexscYEiF4Iku8Gc_kWfQ docs/misc/grant-tables.txt
+ 424d462b5GuApQ_NyMsRFt9LbrsWow docs/misc/sedf_scheduler_mini-HOWTO.txt
  40d6ccbfKKBq8jE0ula4eHEzBiQuDA docs/misc/xen_config.html
  410a4c2bAO_m_l4RsiiPHnZ4ixHWbQ docs/misc/xend.tex
  3f9e7d564bWFB-Czjv1qdmE6o0GqNg docs/src/interface.tex
  41cc934aO1m6NxEh_8eDr9bJIMoLFA tools/libxc/xc_plan9_build.c
  3fbba6dctWRWlFJkYb6hdix2X4WMuw tools/libxc/xc_private.c
  3fbba6dcbVrG2hPzEzwdeV_UC8kydQ tools/libxc/xc_private.h
 -40589968UQFnJeOMn8UIFLbXBuwXjw tools/libxc/xc_rrobin.c
 +42337174PxyzzPk62raDiYCIsfStDg tools/libxc/xc_ptrace.c
+ 41ebbfe9U0b0kI-HgjK7VEY4EvW7_w tools/libxc/xc_sedf.c
 +41dde8b0pLfAKMs_L9Uri2hnzHiCRQ tools/libxc/xc_vmx_build.c
  40e1b09dMYB4ItGCqcMIzirdMd9I-w tools/libxutil/Makefile
  40e033325Sjqs-_4TuzeUEprP_gYFg tools/libxutil/allocate.c
  40e03332KYz7o1bn2MG_KPbBlyoIMA tools/libxutil/allocate.h
  3e54c38dkHAev597bPr71-hGzTdocg xen/common/perfc.c
  4051bcecFeq4DE70p4zGO5setf47CA xen/common/physdev.c
  3ddb79bdHqdQpATqC0rmUZNbsb6L6A xen/common/resource.c
 -4064773cJ31vZt-zhbSoxqft1Jaw0w xen/common/sched_atropos.c
  40589968dD2D1aejwSOvrROg7fOvGQ xen/common/sched_bvt.c
 -40589968be_t_n0-w6ggceW7h-sx0w xen/common/sched_rrobin.c
+ 41ebbfe9oF1BF3cH5v7yE3eOL9uPbA xen/common/sched_sedf.c
  3e397e6619PgAfBbw2XFbXkewvUWgw xen/common/schedule.c
 -3ddb79bdB9RNMnkQnUyZ5C9hhMSQQw xen/common/slab.c
  3ddb79bd0gVQYmL2zvuJnldvD0AGxQ xen/common/softirq.c
  3e7f358awXBC3Vw-wFRwPw18qL1khg xen/common/string.c
  403a3edbejm33XLTGMuinKEwQBrOIg xen/common/trace.c
index eea521875431cf321d820cf61d3c2923ea354b1c,09be85669b25d2771e6e2f022cb565feb76028a8..f0a799f6ce070b433a73c3d396f983f42b97d7e1
@@@ -16,6 -16,8 +16,7 @@@ vpath %c       $(XEN_LIBXUTIL
  INCLUDES += -I $(XEN_LIBXUTIL)
  
  SRCS     :=
 -SRCS     += xc_atropos.c
+ SRCS     += xc_sedf.c
  SRCS     += xc_bvtsched.c
  SRCS     += xc_domain.c
  SRCS     += xc_evtchn.c
index f34dbfc8a9b3a6d61ef4e5e580536b4e5d7300f0,24e35bda39af311615658b57c483cd019f578ef6..c06bf4dfe9b686f21dacc092cbd3ee1fce34f761
@@@ -257,11 -227,33 +257,19 @@@ int xc_bvtsched_domain_get(int xc_handl
                             long long *warpl,
                             long long *warpu);
  
 -int xc_atropos_domain_set(int xc_handle,
 -                          u32 domid,
 -                          u64 period, u64 slice, u64 latency,
 -                          int xtratime);
 -
 -int xc_atropos_domain_get(int xc_handle,
 -                          u32 domid,
 -                          u64* period, u64 *slice, u64 *latency,
 -                          int *xtratime);
 -
 -int xc_rrobin_global_set(int xc_handle, u64 slice);
 -
 -int xc_rrobin_global_get(int xc_handle, u64 *slice);
 -
+ int xc_sedf_domain_set(int xc_handle,
+                           u32 domid,
+                           u64 period, u64 slice, u64 latency, u16 extratime, u16 weight);
+ int xc_sedf_domain_get(int xc_handle,
+                           u32 domid,
+                           u64* period, u64 *slice, u64 *latency, u16 *extratime, u16* weight);
  typedef evtchn_status_t xc_evtchn_status_t;
  
 -/*\
 +/*
   * EVENT CHANNEL FUNCTIONS
 -\*/
 + */
  
  /**
   * This function allocates an unbound port.  Ports are named endpoints used for
index a474c4a888ee7312b35bb576b8174cfc590b2cba,e772494f5f8f0e11841b6b0bbe0c2775e75183a9..cc49c183e585a745bb519a1976544d7818b3b4b0
@@@ -800,6 -715,122 +800,52 @@@ static PyObject *pyxc_physinfo(PyObjec
                           "cpu_khz",     info.cpu_khz);
  }
  
 -static PyObject *pyxc_atropos_domain_set(PyObject *self,
 -                                         PyObject *args,
 -                                         PyObject *kwds)
 -{
 -    XcObject *xc = (XcObject *)self;
 -    u32 domid;
 -    u64 period, slice, latency;
 -    int xtratime;
 -
 -    static char *kwd_list[] = { "dom", "period", "slice", "latency",
 -                                "xtratime", NULL };
 -    
 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLi", kwd_list, &domid,
 -                                     &period, &slice, &latency, &xtratime) )
 -        return NULL;
 -   
 -    if ( xc_atropos_domain_set(xc->xc_handle, domid, period, slice,
 -                               latency, xtratime) != 0 )
 -        return PyErr_SetFromErrno(xc_error);
 -
 -    Py_INCREF(zero);
 -    return zero;
 -}
 -
 -static PyObject *pyxc_atropos_domain_get(PyObject *self,
 -                                         PyObject *args,
 -                                         PyObject *kwds)
 -{
 -    XcObject *xc = (XcObject *)self;
 -    u32 domid;
 -    u64 period, slice, latency;
 -    int xtratime;
 -    
 -    static char *kwd_list[] = { "dom", NULL };
 -
 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &domid) )
 -        return NULL;
 -    
 -    if ( xc_atropos_domain_get( xc->xc_handle, domid, &period,
 -                                &slice, &latency, &xtratime ) )
 -        return PyErr_SetFromErrno(xc_error);
 -
 -    return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}",
 -                         "domain",  domid,
 -                         "period",  period,
 -                         "slice",   slice,
 -                         "latency", latency,
 -                         "xtratime", xtratime);
 -}
 -
 -
 -static PyObject *pyxc_rrobin_global_set(PyObject *self,
 -                                        PyObject *args,
 -                                        PyObject *kwds)
 -{
 -    XcObject *xc = (XcObject *)self;
 -    u64 slice;
 -    
 -    static char *kwd_list[] = { "slice", NULL };
 -
 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &slice) )
 -        return NULL;
 -    
 -    if ( xc_rrobin_global_set(xc->xc_handle, slice) != 0 )
 -        return PyErr_SetFromErrno(xc_error);
 -    
 -    Py_INCREF(zero);
 -    return zero;
 -}
 -
+ static PyObject *pyxc_sedf_domain_set(PyObject *self,
+                                          PyObject *args,
+                                          PyObject *kwds)
+ {
+     XcObject *xc = (XcObject *)self;
+     u32 domid;
+     u64 period, slice, latency;
+     u16 extratime, weight;
+     static char *kwd_list[] = { "dom", "period", "slice", "latency", "extratime", "weight",NULL };
+     
+     if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLhh", kwd_list, &domid,
+                                      &period, &slice, &latency, &extratime, &weight) )
+         return NULL;
+    if ( xc_sedf_domain_set(xc->xc_handle, domid, period, slice, latency, extratime,weight) != 0 )
+         return PyErr_SetFromErrno(xc_error);
+     Py_INCREF(zero);
+     return zero;
+ }
+ static PyObject *pyxc_sedf_domain_get(PyObject *self,
+                                          PyObject *args,
+                                          PyObject *kwds)
+ {
+     XcObject *xc = (XcObject *)self;
+     u32 domid;
+     u64 period, slice,latency;
+     u16 weight, extratime;
+     
+     static char *kwd_list[] = { "dom", NULL };
+     if( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &domid) )
+         return NULL;
+     
+     if ( xc_sedf_domain_get( xc->xc_handle, domid, &period,
+                                 &slice,&latency,&extratime,&weight) )
+         return PyErr_SetFromErrno(xc_error);
+     return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}",
+                          "domain",    domid,
+                          "period",    period,
+                          "slice",     slice,
+                        "latency",   latency,
+                        "extratime", extratime);
+ }
  static PyObject *pyxc_shadow_control(PyObject *self,
                                       PyObject *args,
                                       PyObject *kwds)
@@@ -992,6 -1027,68 +1038,30 @@@ static PyMethodDef pyxc_methods[] = 
        " warpu  [long]: Unwarp requirement.\n"
        " warpl  [long]: Warp limit,\n"
      },
 -
 -    { "atropos_domain_set",
 -      (PyCFunction)pyxc_atropos_domain_set,
 -      METH_KEYWORDS, "\n"
 -      "Set the scheduling parameters for a domain when running with Atropos.\n"
 -      " dom      [int]:  domain to set\n"
 -      " period   [long]: domain's scheduling period\n"
 -      " slice    [long]: domain's slice per period\n"
 -      " latency  [long]: wakeup latency hint\n"
 -      " xtratime [int]: boolean\n"
 -      "Returns: [int] 0 on success; -1 on error.\n" },
 -
 -    { "atropos_domain_get",
 -      (PyCFunction)pyxc_atropos_domain_get,
 -      METH_KEYWORDS, "\n"
 -      "Get the current scheduling parameters for a domain when running with\n"
 -      "the Atropos scheduler."
 -      " dom      [int]: domain to query\n"
 -      "Returns:  [dict]\n"
 -      " domain   [int]: domain ID\n"
 -      " period   [long]: scheduler period\n"
 -      " slice    [long]: CPU reservation per period\n"
 -      " latency  [long]: unblocking latency hint\n"
 -      " xtratime [int] : 0 if not using slack time, nonzero otherwise\n" },
 -
 -    { "rrobin_global_set",
 -      (PyCFunction)pyxc_rrobin_global_set,
 -      METH_KEYWORDS, "\n"
 -      "Set Round Robin scheduler slice.\n"
 -      " slice [long]: Round Robin scheduler slice\n"
 -      "Returns: [int] 0 on success, throws an exception on failure\n" },
 -
 -    { "rrobin_global_get",
 -      (PyCFunction)pyxc_rrobin_global_get,
 -      METH_KEYWORDS, "\n"
 -      "Get Round Robin scheduler settings\n"
 -      "Returns [dict]:\n"
 -      " slice  [long]: Scheduler time slice.\n" },    
+     
+     { "sedf_domain_set",
+       (PyCFunction)pyxc_sedf_domain_set,
+       METH_KEYWORDS, "\n"
+       "Set the scheduling parameters for a domain when running with Atropos.\n"
+       " dom       [int]:  domain to set\n"
+       " period    [long]: domain's scheduling period\n"
+       " slice     [long]: domain's slice per period\n"
+       " latency   [long]: domain's wakeup latency hint\n"
+       " extratime [int]:  domain aware of extratime?\n"
+       "Returns: [int] 0 on success; -1 on error.\n" },
+     { "sedf_domain_get",
+       (PyCFunction)pyxc_sedf_domain_get,
+       METH_KEYWORDS, "\n"
+       "Get the current scheduling parameters for a domain when running with\n"
+       "the Atropos scheduler."
+       " dom       [int]: domain to query\n"
+       "Returns:   [dict]\n"
+       " domain    [int]: domain ID\n"
+       " period    [long]: scheduler period\n"
+       " slice     [long]: CPU reservation per period\n"
+       " latency   [long]: domain's wakeup latency hint\n"
+       " extratime [int]:  domain aware of extratime?\n"},
  
      { "evtchn_alloc_unbound", 
        (PyCFunction)pyxc_evtchn_alloc_unbound,
index e25bababf5ac1ab4a0d2d6a8fe5d1e227423934f,fc14e307b02f5b3181cc30c2bb75404b6d19f660..c762cb64a91ae247019095ec4805ca47788ac35c
@@@ -260,6 -265,23 +260,15 @@@ class Xend
                                'warpl'    : warpl,
                                'warpu'    : warpu })
  
 -    def xend_domain_cpu_atropos_set(self, id, period, slice, latency, xtratime):
 -        return self.xendPost(self.domainurl(id),
 -                             {'op'      : 'cpu_atropos_set',
 -                              'period'  : period,
 -                              'slice'   : slice,
 -                              'latency' : latency,
 -                              'xtratime': xtratime })
 -
+     def xend_domain_cpu_sedf_set(self, id, period, slice, latency, extratime, weight):
+         return self.xendPost(self.domainurl(id),
+                              {'op'        : 'cpu_sedf_set',
+                               'period'    : period,
+                               'slice'     : slice,
+                             'latency'   : latency,
+                             'extratime' : extratime,
+                             'weight'    : weight })
      def xend_domain_maxmem_set(self, id, memory):
          return self.xendPost(self.domainurl(id),
                               { 'op'     : 'maxmem_set',
index 7f5218bff1e88f39a588dda4ab636a07a451b5c5,2d4656266010e163ef90a37e25edaba70dd714f3..93930e9d4fa86934567d53765a843a533522fabb
@@@ -642,6 -642,42 +642,24 @@@ class XendDomain
          except Exception, ex:
              raise XendError(str(ex))
      
 -    def domain_cpu_atropos_set(self, id, period, slice, latency, xtratime):
 -        """Set Atropos scheduler parameters for a domain.
 -        """
 -        dominfo = self.domain_lookup(id)
 -        try:
 -            return xc.atropos_domain_set(dominfo.dom, period, slice, latency, xtratime)
 -        except Exception, ex:
 -            raise XendError(str(ex))
 -
 -    def domain_cpu_atropos_get(self, id):
 -        """Get Atropos scheduler parameters for a domain.
 -        """
 -        dominfo = self.domain_lookup(id)
 -        try:
 -            return xc.atropos_domain_get(dominfo.dom)
 -        except Exception, ex:
 -            raise XendError(str(ex))
+     
+     def domain_cpu_sedf_set(self, id, period, slice, latency, extratime, weight):
+         """Set Simple EDF scheduler parameters for a domain.
+         """
+       dominfo = self.domain_lookup(id)
+         try:
+             return xc.sedf_domain_set(dominfo.dom, period, slice, latency, extratime, weight)
+         except Exception, ex:
+             raise XendError(str(ex))
+     def domain_cpu_sedf_get(self, id):
+         """Get Atropos scheduler parameters for a domain.
+         """
+         dominfo = self.domain_lookup(id)
+         try:
+             return xc.sedf_domain_get(dominfo.dom)
+         except Exception, ex:
+             raise XendError(str(ex))
 -
      def domain_device_create(self, id, devconfig):
          """Create a new device for a domain.
  
index 698da4624c904195facf4a011bb5c2a4ecd41b2b,83d3bd6b7d6755205a21f78cb2098faf7d1642fd..0bc011337ee683f5fa78fa0b6fac8d56f87ceb5a
@@@ -107,6 -107,27 +107,18 @@@ class SrvDomain(SrvDir)
          val = fn(req.args, {'dom': self.dom.id})
          return val
      
 -    def op_cpu_atropos_set(self, op, req):
 -        fn = FormFn(self.xd.domain_cpu_atropos_set,
 -                    [['dom', 'str'],
 -                     ['period', 'int'],
 -                     ['slice', 'int'],
 -                     ['latency', 'int'],
 -                     ['xtratime', 'int']])
 -        val = fn(req.args, {'dom': self.dom.id})
 -        return val
+     
+     def op_cpu_sedf_set(self, op, req):
+         fn = FormFn(self.xd.domain_cpu_sedf_set,
+                     [['dom', 'str'],
+                      ['period', 'int'],
+                      ['slice', 'int'],
+                    ['latency', 'int'],
+                    ['extratime', 'int'],
+                    ['weight', 'int']])
+         val = fn(req.args, {'dom': self.dom.id})
+         return val
      def op_maxmem_set(self, op, req):
          fn = FormFn(self.xd.domain_maxmem_set,
                      [['dom', 'str'],
index a3fb9c75f3f79f1f65f5db295971722fb21675b1,11b7617c03deab78024e01de57e73e4aa1cb59d0..f7d29ff5abacf346e279bedaaa6a9e558db3ae42
@@@ -591,6 -566,57 +591,23 @@@ class ProgBvtslice(Prog)
  
  xm.prog(ProgBvtslice)
  
 -
 -class ProgAtropos(Prog):
 -    group = 'scheduler'
 -    name= "atropos"
 -    info = """Set atropos parameters."""
 -
 -    def help(self, args):
 -        print args[0], "DOM PERIOD SLICE LATENCY XTRATIME"
 -        print "\nSet atropos parameters."
 -
 -    def main(self, args):
 -        if len(args) != 6: self.err("%s: Invalid argument(s)" % args[0])
 -        dom = args[1]
 -        v = map(int, args[2:6])
 -        server.xend_domain_cpu_atropos_set(dom, *v)
 -
 -xm.prog(ProgAtropos)
 -
 -class ProgRrobin(Prog):
 -    group = 'scheduler'
 -    name = "rrobin"
 -    info = """Set round robin slice."""
 -
 -    def help(self, args):
 -        print args[0], "SLICE"
 -        print "\nSet round robin scheduler slice."
 -
 -    def main(self, args):
 -        if len(args) != 2: self.err("%s: Invalid argument(s)" % args[0])
 -        rrslice = int(args[1])
 -        server.xend_node_rrobin_set(rrslice)
 -
 -xm.prog(ProgRrobin)
 -
+ class ProgSedf(Prog):
+     group = 'scheduler'
+     name= "sedf"
+     info = """Set simple EDF parameters."""
+     def help(self, args):
+         print args[0], "DOM PERIOD SLICE LATENCY EXTRATIME WEIGHT"
+         print "\nSet simple EDF parameters."
+     def main(self, args):
+       if len(args) != 7: self.err("%s: Invalid argument(s)" % args[0])
+       dom = args[1]
+       v = map(int, args[2:7])
+       server.xend_domain_cpu_sedf_set(dom, *v)
+ xm.prog(ProgSedf)
  class ProgInfo(Prog):
      group = 'host'
      name = "info"
index 8062fdac73fcae32608a0db662f65baea2762df6,e757cc1bbd24175ebd69028bb3ef894df4e3dd4f..697d8a3757d1ac36b146c8164da67aa409ace44e
  static char opt_sched[10] = "bvt";
  string_param("sched", opt_sched);
  
+ /*#define WAKE_HISTO*/
+ /*#define BLOCKTIME_HISTO*/
+ /*#define ADV_SCHED_HISTO*/
+ //#include <xen/adv_sched_hist.h>
+ #if defined(WAKE_HISTO)
+ #define BUCKETS 31
+ #elif defined(BLOCKTIME_HISTO)
+ #define BUCKETS 200
+ #endif
  #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
  
 -/*
 - * TODO MAW pull trace-related #defines out of here and into an auto-generated
 - * header file later on!
 - */
 -#define TRC_SCHED_DOM_ADD             0x00010000
 -#define TRC_SCHED_DOM_REM             0x00010001
 -#define TRC_SCHED_WAKE                0x00010002
 -#define TRC_SCHED_BLOCK               0x00010003
 -#define TRC_SCHED_YIELD               0x00010004
 -#define TRC_SCHED_SET_TIMER           0x00010005
 -#define TRC_SCHED_CTL                 0x00010006
 -#define TRC_SCHED_ADJDOM              0x00010007
 -#define TRC_SCHED_RESCHED             0x00010008
 -#define TRC_SCHED_SWITCH              0x00010009
 -#define TRC_SCHED_S_TIMER_FN          0x0001000A
 -#define TRC_SCHED_T_TIMER_FN          0x0001000B
 -#define TRC_SCHED_DOM_TIMER_FN        0x0001000C
 -
  /* Various timer handlers. */
  static void s_timer_fn(unsigned long unused);
  static void t_timer_fn(unsigned long unused);
  static void dom_timer_fn(unsigned long data);
  
  /* This is global for now so that private implementations can reach it */
 -schedule_data_t schedule_data[NR_CPUS];
 +struct schedule_data schedule_data[NR_CPUS];
  
  extern struct scheduler sched_bvt_def;
 -extern struct scheduler sched_rrobin_def;
 -extern struct scheduler sched_atropos_def;
+ extern struct scheduler sched_sedf_def;
  static struct scheduler *schedulers[] = { 
      &sched_bvt_def,
 -    &sched_rrobin_def,
 -    &sched_atropos_def,
+     &sched_sedf_def,
      NULL
  };
  
@@@ -221,27 -196,26 +234,35 @@@ void domain_wake(struct exec_domain *ed
  /* Block the currently-executing domain until a pertinent event occurs. */
  long do_block(void)
  {
 -    ASSERT(current->id != IDLE_DOMAIN_ID);
 -    current->shared_info->vcpu_data[0].evtchn_upcall_mask = 0;
 -    set_bit(DF_BLOCKED, &current->flags);
 -    TRACE_2D(TRC_SCHED_BLOCK, current->id, current);
 -    __enter_scheduler();
 +    struct exec_domain *ed = current;
 +
+ #ifdef ADV_SCHED_HISTO
+     adv_sched_hist_start(current->processor);
+ #endif
 +    ed->vcpu_info->evtchn_upcall_mask = 0;
 +    set_bit(EDF_BLOCKED, &ed->ed_flags);
 +
 +    /* Check for events /after/ blocking: avoids wakeup waiting race. */
 +    if ( event_pending(ed) )
 +        clear_bit(EDF_BLOCKED, &ed->ed_flags);
 +    else
 +    {
 +        TRACE_2D(TRC_SCHED_BLOCK, ed->domain->id, ed->eid);
 +        __enter_scheduler();
 +    }
 +
      return 0;
  }
  
  /* Voluntarily yield the processor for this allocation. */
  static long do_yield(void)
  {
 -    TRACE_2D(TRC_SCHED_YIELD, current->id, current);
+ #ifdef ADV_SCHED_HISTO
+     adv_sched_hist_start(current->processor);
+ #endif
+     
 +    TRACE_2D(TRC_SCHED_YIELD, current->domain->id, current->eid);
      __enter_scheduler();
      return 0;
  }
@@@ -381,11 -374,16 +408,14 @@@ static void __enter_scheduler(void
  
      spin_unlock_irq(&schedule_data[cpu].schedule_lock);
  
-     if ( unlikely(prev == next) )
+     if ( unlikely(prev == next) ) {
+ #ifdef ADV_SCHED_HISTO
+         adv_sched_hist_to_stop(cpu);
+ #endif
          return;
-     
+     }
      perfc_incrc(sched_ctx);
  
 -    cleanup_writable_pagetable(prev);
 -
  #if defined(WAKE_HISTO)
      if ( !is_idle_task(next->domain) && next->wokenup ) {
          ulong diff = (ulong)(now - next->wokenup);
      }
  #endif
  
 -    TRACE_2D(TRC_SCHED_SWITCH, next->id, next);
 -    switch_to(prev, next);
 -
 -    /*
 -     * We do this late on because it doesn't need to be protected by the
 -     * schedule_lock, and because we want this to be the very last use of
 -     * 'prev' (after this point, a dying domain's info structure may be freed
 -     * without warning). 
 -     */
 -    clear_bit(DF_RUNNING, &prev->flags);
 +    prev->sleep_tick = schedule_data[cpu].tick;
  
      /* Ensure that the domain has an up-to-date time base. */
 -    if ( !is_idle_task(next) && update_dom_time(next) )
 -        send_guest_virq(next, VIRQ_TIMER);
 +    if ( !is_idle_task(next->domain) )
 +    {
 +        update_dom_time(next);
 +        if ( next->sleep_tick != schedule_data[cpu].tick )
 +            send_guest_virq(next, VIRQ_TIMER);
 +    }
  
 +    TRACE_4D(TRC_SCHED_SWITCH,
 +             prev->domain->id, prev->eid,
 +             next->domain->id, next->eid);
  
 -    schedule_tail(next);
+ #ifdef ADV_SCHED_HISTO
+     adv_sched_hist_to_stop(cpu);
+ #endif
 -    BUG();
 +    context_switch(prev, next);
  }
  
  /* No locking needed -- pointer comparison is safe :-) */
@@@ -436,9 -441,14 +470,13 @@@ int idle_cpu(int cpu
   * - dom_timer: per domain timer to specifiy timeout values
   ****************************************************************************/
  
 -/* The scheduler timer: force a run through the scheduler*/
 +/* The scheduler timer: force a run through the scheduler */
  static void s_timer_fn(unsigned long unused)
  {
 -    TRACE_0D(TRC_SCHED_S_TIMER_FN);
+ #ifdef ADV_SCHED_HISTO
+     adv_sched_hist_start(current->processor);
+ #endif
      raise_softirq(SCHEDULE_SOFTIRQ);
      perfc_incrc(sched_irq);
  }
@@@ -585,13 -647,4 +679,14 @@@ void reset_sched_histo(unsigned char ke
  void print_sched_histo(unsigned char key) { }
  void reset_sched_histo(unsigned char key) { }
  #endif
+ #endif
 +
 +/*
 + * Local variables:
 + * mode: C
 + * c-set-style: "BSD"
 + * c-basic-offset: 4
 + * tab-width: 4
 + * indent-tabs-mode: nil
 + * End:
 + */
index ac376d42267dfca2dfbb69cd03895c944802b25c,5c21769485524e9f26302d51e73d64f1d5597424..01d6481c6e9ab9839d2e6b37c1cbef218feec640
@@@ -7,10 -7,14 +7,11 @@@
  #ifndef __XEN_PUBLIC_SCHED_CTL_H__
  #define __XEN_PUBLIC_SCHED_CTL_H__
  
 -/* Scheduler types */
 +/* Scheduler types. */
  #define SCHED_BVT      0
 -#define SCHED_ATROPOS  2
 -#define SCHED_RROBIN   3
+ #define SCHED_SEDF     4
  
 -/* these describe the intended direction used for a scheduler control or domain
 - * command */
 +/* Set or get info? */
  #define SCHED_INFO_PUT 0
  #define SCHED_INFO_GET 1
  
@@@ -31,18 -43,39 +32,31 @@@ struct sched_ctl_cm
  
  struct sched_adjdom_cmd
  {
-     u32     sched_id;
-     u32     direction;
-     domid_t domain;
-     union {
-         struct bvt_adjdom {
-             u32 mcu_adv;            /* mcu advance: inverse of weight */
-             u32 warpback;           /* warp? */
-             s32 warpvalue;          /* warp value */
-             long long warpl;        /* warp limit */
-             long long warpu;        /* unwarp time requirement */
-         } bvt;
-     } u;
- };
+     u32     sched_id;                 /*  0 */
+     u32     direction;                /*  4 */
+     domid_t domain;                   /*  8 */
+     u16     __pad0;
+     u32     __pad1;
+     union {                           /* 16 */
+         struct bvt_adjdom
+         {
+             u32 mcu_adv;            /* 16: mcu advance: inverse of weight */
+             u32 warpback;           /* 20: warp? */
+             s32 warpvalue;          /* 24: warp value */
+             long long warpl;        /* 32: warp limit */
+             long long warpu;        /* 40: unwarp time requirement */
+         } PACKED bvt;
 -
 -        struct atropos_adjdom
 -        {
 -            u64 nat_period; /* 16 */
 -            u64 nat_slice;  /* 24 */
 -            u64 latency;    /* 32 */
 -            u32 xtratime;   /* 36 */
 -        } PACKED atropos;
+         
+       struct sedf_adjdom
+         {
+             u64 period;     /* 16 */
+             u64 slice;      /* 24 */
+             u64 latency;    /* 32 */
+             u16 extratime;  /* 36 */
+           u16 weight;     /* 38 */
+         } PACKED sedf;
+     } PACKED u;
+ } PACKED; /* 40 bytes */
  
  #endif /* __XEN_PUBLIC_SCHED_CTL_H__ */
index 3e352f4fe88ad40af12341dd74d8189d1365294a,a33b0559ed11c5183a745613576a8e45d11b7e06..7cd5295feaa5e2356aa23d6828ce8387fd0504c0
@@@ -5,16 -7,23 +5,25 @@@
   * Portions by Mark Williamson are (C) 2004 Intel Research Cambridge
   */
  
 -typedef struct schedule_data_st
 -{
 -    spinlock_t          schedule_lock;  /* spinlock protecting curr pointer
 -                                            TODO check this */
 -    struct domain       *curr;          /* current task */
 -    struct domain       *idle;          /* idle task for this cpu */
 -    void *              sched_priv;
 -    struct ac_timer     s_timer;        /* scheduling timer  */
 +#ifndef __XEN_SCHED_IF_H__
 +#define __XEN_SCHED_IF_H__
 +
+ //#define ADV_SCHED_HISTO
+ #define BUCKETS  10
+ /*300*/
 +struct schedule_data {
 +    spinlock_t          schedule_lock;  /* spinlock protecting curr        */
 +    struct exec_domain *curr;           /* current task                    */
 +    struct exec_domain *idle;           /* idle task for this cpu          */
 +    void               *sched_priv;
 +    struct ac_timer     s_timer;        /* scheduling timer                */
 +    unsigned long       tick;           /* current periodic 'tick'         */
+ #ifdef ADV_SCHED_HISTO
+     u32                       to_hist[BUCKETS];
+     u32                       from_hist[BUCKETS];
+     u64                       save_tsc;
+ #endif
  #ifdef BUCKETS
      u32                 hist[BUCKETS];  /* for scheduler latency histogram */
  #endif